package belle.com.myapp.view.home.fragment;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;

import belle.com.myapp.R;
import belle.com.myapp.adapter.BaseFragmentPagerAdapter;
import belle.com.myapp.base.BaseFragment;
import butterknife.BindView;

/**
 * Title :推荐音乐
 * Description :
 * Author:  Belle Guan    date : 2018/5/16 13:45
 * Update :                date :
 * Version : 1.0.0
 * Copyright : copyright(c) 浙江亚厦股份有限公司 2017 ~ 2020 版权所有
 *
 * @author guanjiali1
 */
public class RecommendFragment extends BaseFragment {
    @BindView(R.id.tabs)
    TabLayout tabs;
    @BindView(R.id.view_pager)
    ViewPager viewPager;

    private String[] mTitles = {"推荐", "朋友", "电台"};
    private ArrayList<Fragment> fragments = new ArrayList<>();

    @Override
    protected int getLayoutId() {
        return R.layout.recommend_fragment;
    }

    @Override
    protected void initView(View view, Bundle savedInstanceState) {
        tabs.setupWithViewPager(viewPager);
        setTopTab();
    }

    private void setTopTab() {
        SongFragment songFragment = new SongFragment();
        fragments.add(songFragment);
        MainFragment mainFragment = new MainFragment();
        fragments.add(mainFragment);
        VideoFragment videoFragment = new VideoFragment();
        fragments.add(videoFragment);
        /**
         * 设置viewPager适配器
         */
        if (viewPager != null) {
            viewPager.setAdapter(new BaseFragmentPagerAdapter(getChildFragmentManager(), fragments, mTitles));
            viewPager.setOffscreenPageLimit(fragments.size());
            tabs.setupWithViewPager(viewPager);
        }
    }

    @Override
    protected boolean isNeedEventBus() {
        return false;
    }

    @Override
    protected View initViews(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return null;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void setDefaultFragmentTitle(String title) {

    }
}
